Filter hook 'customize_sanitize_js_{$this->id}'

in WP Core File wp-includes/class-wp-customize-setting.php at line 807

View Source

customize_sanitize_js_{$this->id}

Filter Hook
Description
Filters a Customize setting value for use in JavaScript. The dynamic portion of the hook name, `$this->id`, refers to the setting ID.

Hook Information

File Location wp-includes/class-wp-customize-setting.php View on GitHub
Hook Type Filter
Line Number 807

Hook Parameters

Type Name Description
mixed $value The setting value.
WP_Customize_Setting $setting WP_Customize_Setting instance.

Usage Examples

Basic Usage
<?php
// Hook into customize_sanitize_js_{$this->id}
add_filter('customize_sanitize_js_{$this->id}', 'my_custom_filter', 10, 2);

function my_custom_filter($value, $setting) {
    // Your custom filtering logic here
    return $value;
}

Source Code Context

wp-includes/class-wp-customize-setting.php:807 - How this hook is used in WordPress core
<?php
 802  		 * @since 3.4.0
 803  		 *
 804  		 * @param mixed                $value   The setting value.
 805  		 * @param WP_Customize_Setting $setting WP_Customize_Setting instance.
 806  		 */
 807  		$value = apply_filters( "customize_sanitize_js_{$this->id}", $this->value(), $this );
 808  
 809  		if ( is_string( $value ) ) {
 810  			return html_entity_decode( $value, ENT_QUOTES, 'UTF-8' );
 811  		}
 812  

PHP Documentation

<?php
/**
		 * Filters a Customize setting value for use in JavaScript.
		 *
		 * The dynamic portion of the hook name, `$this->id`, refers to the setting ID.
		 *
		 * @since 3.4.0
		 *
		 * @param mixed                $value   The setting value.
		 * @param WP_Customize_Setting $setting WP_Customize_Setting instance.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/class-wp-customize-setting.php
Related Hooks

Related hooks will be displayed here in future updates.